﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using Telerik.Web.UI;
using System.Web.UI.HtmlControls;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class TR_Trainers : System.Web.UI.Page
    {
        InitialData_BLL iniData = new InitialData_BLL();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            IncludeJava();
            if (!IsPostBack)
            {
                LoadDataGrid();
            }
        }
        public void IncludeJava()
        {
            HtmlGenericControl script = new HtmlGenericControl();
            script.TagName = "script";
            script.Attributes.Add("type", "text/javascript");
            script.Attributes.Add("src", "../../Scripts/jsfunction.js");
            Page.Header.Controls.Add(script);
        }
        private void LoadDataGrid()
        {
            try
            {
                DataSet ListSalaryCommand = iniData.ListTrainers("");
                RadGrid2.DataSource = ListSalaryCommand.Tables[0];
                RadGrid2.DataBind();
            }
            catch (Exception ex)
            {

            }
        }

        protected void RadGrid2_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                int seq = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Sequence"]);
                iniData.DeleteTrainers(seq, "1");
            }
            if (e.CommandName == "ExpandCollapse")
                return;
            if (e.CommandName == "btnClick")
                return;
            if (e.CommandName == "ToolTip")
                return;
            LoadDataGrid();
        }

        protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                string scr;
                if (e.Item.Cells[5].Text == "1")
                    scr = "<img src='../Images/Buttons/Update.gif'>";
                else
                    scr = "<img src='../Images/Buttons/Cancel.gif'>";
                e.Item.Cells[5].Text = scr;
            }
        }
    }
}
